﻿using UnityEngine;
using System.Collections;
using System;

public static class MathExtension
{
    private static float[] Cos_Array;

    static MathExtension()
    {
        Cos_Array = new float[2000];
        for (int i = 0; i < 2000; i++)
        {
            Cos_Array[i] = Mathf.Cos(i / 1000.0f * Mathf.PI);
        }
    }

    public static float Cos(float x)
    {
        try
        {
            return Cos_Array[(int)(((x / Math.PI) * 1000) % 2000)];
        }
        catch
        {
            Debug.Log(x);
            Debug.Log((x / Math.PI));
            Debug.Log(((x / Math.PI) * 1000));
            Debug.Log(((int)(((x / Math.PI) * 1000) % 2000)));
            throw new ArgumentException();
        }
    }
}
